﻿using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor
{
    /// <summary>
    /// ImagePreviewWindow.xaml 的交互逻辑
    /// </summary>
    public partial class ImagePreviewWindow : MetroWindow
    {
        /// <summary>
        /// [构造方法]用于预览图像的窗口。
        /// </summary>
        /// <param name="imageFilePath">图像文件完整路径。</param>
        public ImagePreviewWindow(string imageFilePath)
        {
            InitializeComponent();

            if (WorkspaceTreeViewItem.IsValidateImageFilePath(imageFilePath))
            {
                previewImage.Source = new BitmapImage(new Uri(imageFilePath));
            }
        }

        /// <summary>
        /// Esc 键关闭窗口退出预览。
        /// </summary>
        private void MetroWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape) this.Close();
        }
    }
}
